package com.ihisun.tmhcms.controller.activitycontroller;

import com.ihisun.tmhcms.core.dto.activitydto.ActivityDto;
import com.ihisun.tmhcms.core.dto.activityrotationdto.ActivityRotationDto;
import com.ihisun.tmhcms.core.service.activityrotationservice.ActivityRotationService;
import com.ihisun.tmhcms.core.service.activityservice.ActivityService;
import com.ihisun.tmhcms.core.vo.ActivityVo;
import com.ihisun.tmhcms.utils.ResponseVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;


@Api(tags = "活动相关Api")
@RestController
@RequestMapping("/activity")
public class ActivityController {
    @Resource
    ActivityService activityService;
    @Resource
    ActivityRotationService activityRotationService;

    @PostMapping("/EditActivity")
    @ApiOperation(value = "编辑活动")
    public ResponseVo EditActivity(@RequestBody ActivityDto activityDto) {
        return activityService.editActivity(activityDto);
    }

    @GetMapping("/updateState")
    @ApiOperation(value = "修改活动状态")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "id", value = "活动图Id", dataType = "String", paramType = "query"),
            @ApiImplicitParam(name = "state", value = "状态", dataType = "Integer", paramType = "query")
    })
    public ResponseVo updateState(String id, Integer state) {
        return activityService.updateState(id, state);
    }

    @GetMapping("/SearchActivity")
    @ApiOperation(value = "广告列表", response = ActivityVo.class)
    @ApiImplicitParams({
            @ApiImplicitParam(name = "title", value = "活动标题", dataType = "String", paramType = "query"),
            @ApiImplicitParam(name = "state", value = "状态", dataType = "Integer", paramType = "query")

    })
    public ResponseVo SearchActivity(String title, Integer state) {
        return activityService.SearchActivity(title, state);
    }

    @PostMapping("/editActivityRotation")
    @ApiOperation(value = "编辑轮播")
    public ResponseVo editActivityRotation(@RequestBody ActivityRotationDto activityRotationDto) {
        return activityRotationService.editActivityRotation(activityRotationDto);
    }

    @GetMapping("/updateActivityRotationState")
    @ApiOperation(value = "修改轮播状态")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "id", value = "轮播图id", dataType = "String", paramType = "query"),
            @ApiImplicitParam(name = "state", value = "状态", dataType = "Integer", paramType = "query")
    })
    public ResponseVo updateActivityRotationState(String id, Integer state) {
        return activityRotationService.updateActivityRotationState(id, state);
    }




}
